package com.sctvcloud.bazhong.ui.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.jiongbull.jlog.JLog;
import com.ruihang.generalibrary.ui.dialog.BaseDialogFragment;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.bazhong.R;

/**
 * Created by Administrator on 2017/5/19.
 */

public class DownLoadDialogFragment extends BaseDialogFragment {
    /* 更新进度条 */
    private ProgressBar mProgress;
    private CustomFontTextView cvProgress,cv_cancel;

    private View.OnClickListener cancelClick;

    @Override
    protected int getContentRes() {
        isNoDefTitle=false;
        return R.layout.soft_update_progress;
    }

    @Override
    protected void initViews(Dialog dialog, Bundle savedInstanceState) {
        dialog.setTitle(R.string.soft_updating);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setCancelable(false);
        mProgress = (ProgressBar) dialog.findViewById(R.id.update_progress);
        cvProgress = (CustomFontTextView) dialog.findViewById(R.id.cv_progress);
        cv_cancel=(CustomFontTextView) dialog.findViewById(R.id.cv_cancel) ;
        if (cancelClick!=null){
            cv_cancel.setOnClickListener(cancelClick);
        }
        JLog.e("mprogress="+mProgress);
    }

    public void setProgress(int i,String progressTx){
        if (mProgress!=null) {
            mProgress.setProgress(i);
            cvProgress.setText(progressTx);
        }
    }

    public DownLoadDialogFragment setCancelClick(View.OnClickListener cancelClick) {
        this.cancelClick = cancelClick;
        return this;
    }
}
